package com.nl.pulsardemo.not.commons;

import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.MessageRouter;
import org.apache.pulsar.client.api.TopicMetadata;

/**
 * @author : ZhaoY
 * @description : 自定义主题分区路由规则
 * @date : 2021-01-26 14:39
 **/
public class MyRouteMode implements MessageRouter {
    @Override
    public int choosePartition(Message<?> msg, TopicMetadata metadata) {
//        System.out.println("msg内容"+new String(msg.getData()));
        //共10个分区取模计算
//        return Integer.valueOf(new String(msg.getData()))%10;
        return  1;
    }
}
